
#ifndef _M_APP_XC_H_
#define	_M_APP_XC_H_

#define MAX_TEMP_DATA_SIZE 	12
#define XC_CONNECT_TIMEOUT  20000 //20s
#define XC_LOGIN_TIMEOUT    40000 //50s

#define	P2P_SYN						"SYN"
#define	P2P_ACK						"ACK"
#define	P2P_FIN						"FIN"

#define	P2P_SYN_CKECK			1
#define	P2P_ACK_CKECK			2
#define	P2P_FIN_CKECK			3

enum PRE_STAT{
  XS_PRE_NORMAL = 0,
  XS_COMPORT_ERR,
  XS_DATA_ERR,
  XS_WFLASH_ERR,
  XS_NO_CFG,
};

enum PRE_CMD{
  XS_RESTART = 0,
  XS_SET_CFG = 1,
  XS_SET_TRAFFIC = 2,
  XS_GET_CFG = 3,
  XS_CMD_TEST = 4,
};

typedef struct _xsNetSR_t
{
  unsigned int uiRILen;
  unsigned int uiROLen;
  char cRBuf[XS_TCP_RBUF_SIZE];
}xsNetSR_t;

typedef struct _xsNatINfo_t
{
	unsigned char   ucType;
	unsigned char   aucMapIp[4];
	unsigned int    uiMapHexIp;
	unsigned short  usMapPort;
	
}xsNatINfo_t;

enum XC_PROC_STEP{
	P_INIT = 0,
  P_DNS_REQ,
  P_DNS_CHECK,
	P_TCP_CONNECT,
	P_WAIT_CONNECTED,
	P_LOGIN,
	P_UDP_CONNECT,
	P_GET_NAT,
	P_REQ,
	P_GET_REP,
	P_CHECK,
	P_HEARBEAT,
	P_GET_CFG,
	P_CMD_RES,
	P_LOGOUT,
	P_RELEASE,
};

enum P2P_STAT{
	P2P_CHECKING = 0,
	P2P_OK,
	P2P_FORWARD,
	P2P_FAIL,
};

int xc_proc_init(void);
int xc_main_proc(unsigned char ucResetFlag);
int xc_release(void);

int UdpSend(unsigned int uiDstIP, unsigned short usDstPort, unsigned char *pucSData, unsigned int uiLen);
int UdpRecv(unsigned int uiDstIP, unsigned short usDstPort, unsigned char *pucBuf, unsigned int uiSize);

#endif

